<template>
	<view class="content" v-if="extraData">
		<v-calendar name="calendar" :defaultTime="time" :extraData="extraData" @calendarTap="calendarTap"
			@monthTap="monthTap" />
	</view>
</template>
<script>
	import calendar from '@/components/tale-calendar/calendar.vue';
	export default {
		data() {
			return {
				time: {
		
				},
				id: '',
				ad: false,
				extraData: [
					{
						date: '2020-6-3',
						title: '签',
						count: 99,
					}
				],
				month: {
					year: 2020,
					month: 6
				}
			}
		},
		components: {
			'v-calendar': calendar
		},
		onReady() {
		},
		onLoad(e) {
			this.id = e.id
			this.getdata()
this.time =  this.getCurrentYearAndMonth();

		},
		methods: {
			 getCurrentYearAndMonth() {
			  const now = new Date(); // 获取当前日期和时间
			  const year = now.getFullYear(); // 获取当前年份
			  const month = now.getMonth() ; // 获取当前月份，注意月份是从0开始的，所以需要加1 + 1
			
			  return {
			    year: year,
			    month: month
			  };
			},
			 getdata() {
				this.$http.getGoodSchedule({
					id: this.id
				}).then((result) => {
						this.extraData = result.data
						this.ad = true
						console.log(	this.extraData,'	this.extraData')
				});
			},
			calendarTap(e) {
				console.log(e);
			},
			monthTap(val) {
				let {
					year,
					month
				} = val;
				this.month = {
					year: year,
					month: month,
				}
				// 此处获取动态的数据，赋值给extraData
				this.extraData = [{
					date: '2020-11-3',
					value: '签到',
					dot: true,
					active: true
				}];
			}
		}
	}
</script>